// pages/mine/myInformation/myInformation.js
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    src: '', // 头像
    value: '', // 姓名
    name: '偏执狂呀',
    storeName: '', // 门店品牌
    address:'', // 门店地址
  },
  //跳转个人网络店铺
  goOnlineShop() {
    let that = this;
    var settingInfo = wx.getStorageSync('settingInfo');
    var loginUserInfo = getApp().globalData.loginUserInfo;
    if(that.jump) {
      wx.redirectTo({
        url: that.jump,
      })
      return
    }
    if(app.globalData.isFirstShop){
      app.globalData.isFirstShop=false;
      wx.navigateTo({
        url: '/pages/mine/onlineShop/onlineShop?imgArray=' + that.data.src + '&name=' + that.data.value + '&storeName=' + that.data.storeName + '&address=' + that.data.address + '&tel=' + settingInfo.tel + '&agentId=' + loginUserInfo.data.content.sessionUser.id,
      })
    } else {
      wx.navigateTo({
        url: '/pages/mine/onlineShop/onlineShop?imgArray=' + that.data.src + '&name=' + that.data.value + '&storeName=' + that.data.storeName + '&address=' + that.data.address + '&tel=' + settingInfo.tel + '&agentId=' + loginUserInfo.data.content.sessionUser.id,
      })
    }
  },
  //跳转设置详情
  goSetDetail(e) {
    var title = e.currentTarget.dataset.title;
    wx.navigateTo({
      url: '/pages/mine/setDetail/setDetail?title=' + title,
    })
    wx.setStorageSync('isShop', 1)
  },
  // 更新页面信息
  upData(){
    let that = this;
    let user = wx.getStorageSync('user');
    let settingInfo = wx.getStorageSync('settingInfo');
    let loginUserInfo = getApp().globalData.loginUserInfo;
    that.setData({
      value: settingInfo.name ? settingInfo.name : loginUserInfo.data.content.sessionUser.realName,
      src: settingInfo.imgArray ? settingInfo.imgArray : loginUserInfo.data.content.sessionUser.avatar,
      storeName: settingInfo.storeName,
      address: settingInfo.address,
    })
  },
  // 修改头像
  upload() {
    let that = this;
   
    wx.navigateTo({
      url: '/pages/mine/personData/personData',
    })
    wx.setStorageSync('myInformation', 'changHeadimg')
  },
    // 修改姓名
    upName() {
      let that = this;
      wx.navigateTo({
        url: '/pages/mine/personData/personData',
      })
      wx.setStorageSync('myInformation', 'changName')
    },
  
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.upData();
    this.jump = options.jump ? decodeURIComponent(options.jump) : ''
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.upData();
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

})